import java.util.List;

import test.TestData;

import grammar.Design;
import grammar.InstantiationInput;
import grammar.Match;
import grammar.Matcher;
import grammar.Rule;
import graph.GraphMatch;

@SuppressWarnings("all")

public class Main {

	public static void main(String[] args) {
	    //make the initial design
	    Design design = TestData.buildInitial1();
	    //make the rules
	    Rule rule1 = TestData.buildRule1();
        System.out.print("\n\nDESIGN -X-X-X-X-X\n" + design);

        System.out.print("\n\nRULE -X-X-X-X-X\n" + rule1);
	    
	    //find the graph matches
        
	    //where is rule applicable
	    List<Match> matches = Matcher.findRuleMatches(design, rule1);
       
//	    System.out.println("Number of matches = " + matches.size());
//	    System.out.println(matches.get(0));
	    //apply a rule
//	    rule1.apply(design, matches.get(0), new InstantiationInput());
        
//	    System.out.print("\n\nDESIGN -X-X-X-X-X\n" + design);
//	    //output the geometry of the rule
//
//	    matches = Matcher.findRuleMatches(design, rule1);
       
	    System.out.println("\nNumber of matches = " + matches.size());
	    
	    for (Match match : matches) {
	        System.out.print("\n\nMATCH----------------------------------------\n");
	        System.out.print(match);
	    }
	    //apply a rule
//	    rule1.apply(design, matches.get(0), new InstantiationInput());
//        System.out.print("\n\nDESIGN -X-X-X-X-X\n" + design);
//	    System.out.println(design.hasSelfIntersectingGeometry());
	    design.writeVRML("design.wrl");
	}
	
	private static final long MEGABYTE = 1024L * 1024L;

    public static long bytesToMegabytes(long bytes) {
        return bytes / MEGABYTE;
    }
}
